
package test.keter.framework.tx;

import keter.framework.model.Codelist;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.aop.Before;
import com.jfinal.aop.Duang;
import com.jfinal.aop.Enhancer;
import com.jfinal.plugin.activerecord.tx.Tx;


/**
 * <p>Class       : test.tx.CodeListServiceMock
 * <p>Descdription: 模拟codelist service类，用于"事务"测试
 * @author  顾力行-gulixing@msn.com
 * @version 1.0.0
 */
public class CodeListServiceAppMock{
	  /**
     * Logger for this class
     */
    private static final Logger logger = LoggerFactory.getLogger(CodeListServiceAppMock.class);
    
    //只对使用@Before(Tx.class)的方法生效
    public static CodeListServiceAppMock service = Enhancer.enhance(CodeListServiceAppMock.class);

    //对全部方法添加事务
    public static CodeListServiceAppMock serviceTx = Duang.duang(CodeListServiceAppMock.class, Tx.class);
    
    @Before(Tx.class)
    public  void saveEx(Codelist cl1, Codelist cl2){
    	cl1.save();  
    	int a = 1/0;
    	cl2.save();  
    }
    
    
    public  void saveEx2(Codelist cl1, Codelist cl2){
        cl1.save();  
        int a = 1/0;
        cl2.save();  
    }
    
    public  void save(Codelist cl1, Codelist cl2){
    	cl1.save();  
    	cl2.save();  
    }
    
}
